<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/calendar.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
	
		var customerName = document.getElementById("customerName");
		var salePersonId = document.getElementById("salePersonId");
		var industryId = document.getElementById("industryId");
		var areaId = document.getElementById("areaId");
		var startLastLink = document.getElementById("startLastLinkDate");
		var endLastLink = document.getElementById("endLastLinkDate");
		
		
		if(startLastLink.value != ''){
			if(endLastLink.value == ''){
				alert("请选择最后联系结束日期！");
				return false;
			}
		}
		if(endLastLink.value != ''){
			if(startLastLink.value == ''){
				alert("请选择最后联系开始日期！");
				return false;
			}
		}
		if(startLastLink.value != '' && endLastLink.value != ''){
			var d1 = (startLastLink.value).replace("-","/");
			var d2 = (endLastLink.value).replace("-","/");
			if(Date.parse(d1) - Date.parse(d2) > 0){
				alert("最后联系开始日期不能比最后联系结束日期早，请重新选择最后联系开始日期！");
				return false;
			}
		}
		
		if( customerName.value == '' 
			&& salePersonId.value == ''
			&& industryId.value == '' && areaId.value == '' 
			&& startLastLink.value == '' && endLastLink.value == ''){
			alert("请输入查询条件！");
			return false;
		}
		return true;
	}
	
	function queryCustomer(){
		if(checkForm()){
			var customerName = document.getElementById("customerName").value;
			var salePersonId = document.getElementById("salePersonId").value;
			var industryId = document.getElementById("industryId").value;
			var areaId = document.getElementById("areaId").value;
			var startLastLink = document.getElementById("startLastLinkDate").value;
			var endLastLink = document.getElementById("endLastLinkDate").value;
			
			var values =  customerName + "," + salePersonId + "," + industryId + "," + areaId + "," ;
			values +=  startLastLink + "," + endLastLink;
			
			window.returnValue = values;
			self.close();
		}
	}
	
-->
</script>
</head>
<body><br>
	<div class="tools">
		<input class="btn1" type="button" value="确 定" onclick="queryCustomer()"/>&nbsp;&nbsp;
		<input class="btn1" type="button" value="取 消" onclick="window.close();"/>&nbsp;&nbsp;
	</div>
	
<table class="table1">
	<tr>
		<td>
			<table class="table_input" cellpadding="0" cellspacing="0" style="margin: 0 0 0 40px;">
				<tr>
					<td><!-- 客户名称 -->
						客户名称：
					</td>
					<td><input id="customerName" name="customerName" class="input_long" type="text"/></td>
				</tr>
				<tr>
					<td width="20%">共享人：</td>
					<td>
						<select id="salePersonId" name="salePersonId">
							<option value="">----------请选择----------</option>
							<c:forEach var="user" items="${users}">
								<option value="${user.id}">${user.userName}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				
				<tr>
					<td width="20%"><!-- 行业 -->
						行业：
					</td>
					<td width="">
						<select id="industryId" name="industryId">
							<option value="">----------请选择----------</option>
							<c:forEach var="range" items="${ranges['110']}">
							<option value="${range.id}">${range.rangeValue}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width=""><!-- 区域 -->
						区域：
					</td>
					<td width="">
						<select id="areaId" name="areaId">
							<option value="">----------请选择----------</option>
							<c:forEach var="range" items="${ranges['111']}">
							<option value="${range.id}">${range.rangeValue}</option>
							</c:forEach>
						</select>
					</td>
				</tr>				
				<tr>
					<td width="20%">最后联系：</td>
					<td>
						<input id="startLastLinkDate" name="startLastLinkDate" class="input1" type="text" onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>--
						<input id="endLastLinkDate" name="endLastLinkDate" class="input1" type="text" onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>	
</body>
</html>